package inner;

/**
 * Created with IntelliJ IDEA.
 * ClassName: OuterClassTest
 * Package: inner
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-25
 * Time: 15:40
 */

public class OuterClassTest {

    public static void main(String[] args) {

        //创建静态的成员内部类的实例的写法
        Person.Dog dog = new Person.Dog();
        dog.eat();

        //创建Person非静态的成员内部类的实例
        //非静态的 就要从实例出发
        Person p1 = new Person();
        Person.Bird bird = p1.new Bird();
        bird.eat();



    }


}

///外部类
class Person {

    //静态的成员内部类
    //内部类
    static class Dog {

        public void eat() {
            System.out.println("吃骨头");
        }

    }

    //非静态的
    class Bird {
        public void eat() {
            System.out.println("吃虫子");
        }
    }

    public void method() {

        //局部内部类
        class InnerClass1 {

        }

    }

    public Person() {

        //局部内部类
        //构造器当中也可以定义
        class InnerClass2 {

        }

    }

    {
        //代码当中也可以定义局部内部类
        class InnerClass1 {

        }
    }


}
